<template>
    <div>
        <h1>和差问题2</h1>
        <el-form label-width="100px">
            <el-form-item label="两数之和：">
                <el-input-number v-model="sum" :min="1" :max="200" :step="1" @change="calc"></el-input-number>米
            </el-form-item>
            <el-form-item label="两数之差：">
                <el-input-number v-model="diff" :min="0" :max="sum" :step="1" @change="calc"></el-input-number>米
            </el-form-item>
<!--            <el-form-item label="">-->
<!--                <el-button type="primary" @click="calc">计算</el-button>-->
<!--            </el-form-item>-->
        </el-form>
        <div style="padding:10px 10px">
            <p>结果：</p>
            <el-form label-width="100px">
                <el-form-item label="甲：">
                    <el-slider v-model="v1" show-input :disabled="true"></el-slider>
                </el-form-item>
                <el-form-item label="乙：">
                    <el-slider v-model="v2" show-input :disabled="true"></el-slider>
                </el-form-item>
            </el-form>
        </div>

    </div>
</template>

<script>
    export default {
        name: "sum_diff.vue",
        data() {
            return {
                sum: 30,
                diff: 10,
                v1: 0,
                v2: 0,
            }
        },
        methods: {
            calc() {
                this.v2 = parseInt((this.sum - this.diff) / 2)
                this.v1 = this.v2 + parseInt(this.diff)
            }
        },
        mounted() {
            this.calc()
        }
    }
</script>

<style scoped>

</style>
